[+:   -*- Mode: nroff -*-
 AutoGen5 template man=%s.1M                      :+][+:

	# * * * * * * * * * * * * * * * * * * * * * * * * *
	#Start  : definitions
	# * * * * * * * * * * * * * * * * * * * * * * * * *
				
				                  :+][+: 
 (define prog-name   (string-downcase! (get "prog-name")))
 (define PROG_NAME   (string-tr! (get "prog-name") "a-z^-" "A-Z__"))
 (define prog_name   (string-tr! (get "prog-name") "A-Z^-" "a-z__")) 
 (define detail-file (string-append tmp-dir "/detail"))
 (define use-flags   (if (exist? "flag.value") #t #f))  
           					  :+][+:

	# * * * * * * * * * * * * * * * * * * * * * * * * *
	#End   : definitions
	#Start : temporary folders
	# * * * * * * * * * * * * * * * * * * * * * * * * *

				                  :+][+:
 (make-tmp-dir)                                   :+][+:

	# * * * * * * * * * * * * * * * * * * * * * * * * *
	#End   : temporary folders
	#Start : environment variable setting
	# * * * * * * * * * * * * * * * * * * * * * * * * *

				                  :+][+:
 (setenv "SHELL" "/bin/sh")	                  :+][+:

	# * * * * * * * * * * * * * * * * * * * * * * * * *	
	#End   : environment variable setting
	#Start : prog-name section date version package information
	# * * * * * * * * * * * * * * * * * * * * * * * * *

				                  :+][+: 
% prog-name       (string-append ".TH  " "%s" " "):+][+:
% manual-section  (string-append " " "%s" " ")    :+][+:
 `date +%Y-%m-%d`                                 :+][+:
  IF (or (exist? "package") (exist? "version"))   :+][+:
% package         (string-append " \"" "%s" "\" "):+][+:
% version         (string-append " \"" "%s" "\" "):+][+:
  ENDIF 					  :+][+:

	# * * * * * * * * * * * * * * * * * * * * * * * * *
	#End   : prog-name section date version package information
	#Start : dne argument
	# * * * * * * * * * * * * * * * * * * * * * * * * *

						  :+]
.\"						     [+:

;; The following "dne" argument is a string of 5 characters:
;; '.' '\\' '"' and two spaces.  It _is_ hard to read.
;;
(dne ".\\\"  ")

						  :+]
.\"						     [+:

	# * * * * * * * * * * * * * * * * * * * * * * * * *
	#End   : dne argument
	#Start : NAME
	# * * * * * * * * * * * * * * * * * * * * * * * * *

						  :+]
.SH NAME					     
[+:
% prog-name        (string-append ".B " "%s" )     :+][+:
% prog-title 	   (string-append "\n" "\\-" " %s" )     	    :+][+:

	# * * * * * * * * * * * * * * * * * * * * * * * * *
	#End   : NAME
	#Start : SYNOPSIS
	# * * * * * * * * * * * * * * * * * * * * * * * * *

						  :+]
.SH SYNOPSIS					     
[+:
  IF (exist? "argument") 	                  :+][+:
% argument       (string-append ".B " "%s" " " )  :+][+:
  ELSE						  :+][+:
% prog-name      (string-append ".B " "%s" " " )  :+][+:
  ENDIF						  :+][+:
  FOR flag					  :+][+:
% value  (string-append "\n" ".Op Fl " " %s " "Ar " (get "argument")):+][+:
  ENDFOR					  :+][+:	

	# * * * * * * * * * * * * * * * * * * * * * * * * *
	#End   : SYNOPSIS
	#Start : DESCRIPTION
	# * * * * * * * * * * * * * * * * * * * * * * * * *

						  :+]				
.SH DESCRIPTION
[+:
IF   (exist? "prog-man-descrip ")                 :+][+:
  FOR prog-man-descrip  "\n\n"                    :+][+:
    prog-man-descrip                              :+][+:
  ENDFOR                                          :+][+:
ELIF (exist? "prog-mdoc-descrip ")                :+][+:
  (out-push-new detail-file)                      :+][+:
  FOR prog-mdoc-descrip "\n\n"                    :+][+:
    prog-mdoc-descrip 	                          :+][+:
  ENDFOR			                  :+][+:
ELIF (exist? "prog-info-descrip ")                :+][+:
  (out-push-new detail-file)                      :+][+:
  FOR prog-info-descrip  "\n\n"                   :+][+:
    prog-info-descrip                             :+][+:
  ENDFOR			                  :+][+:
ENDIF
                                                  :+][+:
IF   (exist? "prog-mdoc-descrip ")                :+][+:
  (out-pop)		                          :+][+:
  (shellf "perl %s < %s" (find-file "mdoc2man.pl") detail-file)     :+][+:
ELIF (exist? "prog-info-descrip")                 :+][+:
  (out-pop)		                          :+][+:
  (shellf "perl %s < %s" (find-file "texi2man.pl") detail-file)    :+][+:
ENDIF
						  :+][+:	

	# * * * * * * * * * * * * * * * * * * * * * * * * *
	#End   : DESCRIPTION
	#Start : OPTIONS
	# * * * * * * * * * * * * * * * * * * * * * * * * *

						  :+]	
.SH OPTIONS
[+:
  FOR flag					  :+][+:
% value  (string-append  ".TP " "\n" ".BR " " -" "%s " "\n" (get "descrip") "\n" ".sp" "\n" (get "doc") "\n" ):+][+:
  ENDFOR					  :+]
.SH FILES
[+:
IF   (exist? "prog-man-files ")    :+][+:
  FOR prog-man-files  "\n\n"       :+][+:
    prog-man-files                 :+][+:
  ENDFOR                           :+][+:
ELIF (exist? "prog-mdoc-files ")   :+][+:
  (out-push-new detail-file)       :+][+:
  FOR prog-mdoc-files "\n\n"       :+][+:
    prog-mdoc-files 	           :+][+:
  ENDFOR			   :+][+:
ELIF (exist? "prog-info-files ")   :+][+:
  (out-push-new detail-file)       :+][+:
  FOR prog-info-files  "\n\n"      :+][+:
    prog-info-files                :+][+:
  ENDFOR			   :+][+:
ENDIF
:+][+:
IF   (exist? "prog-mdoc-files ")   :+][+:
  (out-pop)		           :+][+:
  (shellf "perl %s < %s" (find-file "mdoc2man.pl") detail-file)     :+][+:
ELIF (exist? "prog-info-files")    :+][+:
  (out-pop)		           :+][+:
  (shellf "perl %s < %s" (find-file "texi2mdoc.pl") detail-file)    :+][+:
ENDIF
:+]
.SH SEE ALSO
[+:
IF   (exist? "prog-man-see-also ")  :+][+:
  FOR prog-man-see-also  "\n\n"     :+][+:
    prog-man-see-also               :+][+:
  ENDFOR                            :+][+:
ELIF (exist? "prog-mdoc-see-also ") :+][+:
  (out-push-new detail-file)        :+][+:
  FOR prog-mdoc-see-also "\n\n"     :+][+:
    prog-mdoc-see-also 	            :+][+:
  ENDFOR			    :+][+:
ELIF (exist? "prog-info-see-also ") :+][+:
  (out-push-new detail-file)        :+][+:
  FOR prog-info-see-also  "\n\n"    :+][+:
    prog-info-see-also              :+][+:
  ENDFOR			    :+][+:
ENDIF
:+][+:
IF   (exist? "prog-mdoc-see-also ") :+][+:
  (out-pop)		            :+][+:
  (shellf "perl %s < %s" (find-file "mdoc2man.pl") detail-file)    :+][+:
ELIF (exist? "prog-info-see-also")  :+][+:
  (out-pop)		            :+][+:
  (shellf "perl %s < %s" (find-file "mdoc2man.pl") detail-file)    :+][+:
ENDIF
:+]
.SH BUGS
[+:IF   (exist? "prog-man-bug")     :+][+:
  FOR prog-man-bug  "\n\n"          :+][+:
    prog-man-bug                    :+][+:
  ENDFOR                            :+][+:
ELIF (exist? "prog-mdoc-bug")       :+][+:
 (out-push-new detail-file)         :+][+:
  FOR prog-mdoc-bug "\n\n"          :+][+:
    prog-mdoc-bug 	            :+][+:
  ENDFOR
:+][+:
ENDIF
:+]
[+: IF (exist? "prog-mdoc-bug"):+]
[+:
  (out-pop)
  :+][+: (shellf "perl %s < %s" (find-file "mdoc2man.pl") detail-file) :+][+: 
ENDIF :+]
